[USER (data scientist)]: Great! Now, can you calculate the surface performance of Raonic M. against each of Federer's opponents? Please define a function to calculate the overall win rate, head-to-head (h2h) record, and performance on different surface types for a specified player against a specific opponent in the ATP tennis dataset.

[YOU (AI assistant)]: Sure, let's modify the existing function to include surface performance calculation: 
'''
import pandas as pd
import numpy as np
import pickle
from decision_company import read_csv_file, fetch_column, logical_and, logical_or, create_dataframe, concatenate_objects, reset_index, search_where, extract_unique_values, update_dict, assert_series


atp_tennis = read_csv_file('atp_tennis.csv')


def calculate_win_rate(player, opponent, data):
    player_matches = data[logical_or(logical_and(assert_series(data['Player_1'], player, 'equality'), assert_series(data['Player_2'], opponent, 'equality')), logical_and(assert_series(data['Player_1'], opponent, 'equality'), assert_series(data['Player_2'], player, 'equality')))]
    total_matches = len(player_matches)
    wins = len(player_matches[assert_series(player_matches['Winner'], player, 'equality')])
    win_rate = wins / total_matches if total_matches > 0 else 0

    return win_rate

'''

[USER (data scientist)]: Cool! Now, I'd like to calculate the win rate of Raonic M. against each of Federer's opponents. Can you help me with that? Please define a function to calculate the win rate of a specified player against a specific opponent in the ATP tennis dataset.

[YOU (AI assistant)]: Sure, let's define a function to calculate the win rate of Raonic M. against a given opponent: 
'''
import pandas as pd
import numpy as np
import pickle
from decision_company import read_csv_file, fetch_column, logical_and, logical_or, create_dataframe, concatenate_objects, reset_index, search_where, extract_unique_values, update_dict, assert_series


atp_tennis = read_csv_file('atp_tennis.csv')


def calculate_win_rate_and_h2h(player, opponent, data):
    player_matches = data[logical_or(logical_and(assert_series(data['Player_1'], player, 'equality'), assert_series(data['Player_2'], opponent, 'equality')), logical_and(assert_series(data['Player_1'], opponent, 'equality'), assert_series(data['Player_2'], player, 'equality')))]
    total_matches = len(player_matches)
    wins = len(player_matches[assert_series(player_matches['Winner'], player, 'equality')])
    win_rate = wins / total_matches if total_matches > 0 else 0

    h2h_record = wins / total_matches if total_matches > 0 else 0

    return win_rate, h2h_record
'''

[USER (data scientist)]: That's a nice function! Can you also calculate the head-to-head record of Raonic M. against each of Federer's opponents? Please define a function to calculate both the win rate and the head-to-head (h2h) record of a specified player against a specific opponent in the ATP tennis dataset. 
My template of code snippet is:

---BEGIN CODE TEMPLATE---

import pandas as pd
import numpy as np
import pickle
from decision_company import read_csv_file,

# please import the necessary private functions from decision_company first

# Load the dataset 
atp_tennis = read_csv_file('atp_tennis.csv')

# YOUR SOLUTION BEGIN:
<code1>
[COMPLETE YOUR CODE] 
</code1>
# YOUR SOLUTION END

---END CODE TEMPLATE---

[YOU (AI assistant)]: Sure, let's add the head-to-head record calculation to the existing function: 
'''
import pandas as pd
import numpy as np
import pickle
from decision_company import read_csv_file,

# please import the necessary private functions from decision_company first

# Load the dataset 
atp_tennis = read_csv_file('atp_tennis.csv')

# YOUR SOLUTION BEGIN:
